package com.health.db.dao.sm.impl;


import java.util.List;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.sm.IGoodsDataDao;
import com.health.db.mapper.GoodsDataMapper;
import com.health.db.model.GoodsData;
import com.health.db.model.GoodsDataExample;
import com.health.redis.RedisConstants;


public class GoodsDataDaoImpl extends ServiceInterface implements IGoodsDataDao{

	private GoodsDataMapper goodsDataMapper;
	
	String  selectByExample=":selectByExample:";

	public GoodsDataMapper getGoodsDataMapper() {
		return goodsDataMapper;
	}

	public void setGoodsDataMapper(GoodsDataMapper goodsDataMapper) {
		this.goodsDataMapper = goodsDataMapper;
	}

	/**
	 * example
	 * {
	 *   goodsid  商品id 可以为空
	 * }
	 */
	@Override
	public List<GoodsData> selectByExample(GoodsDataExample example) {
		
		getRedisOperatiorLogic();
		String key=RedisConstants.GoodsDataMapper+selectByExample+example.getGoodsid();
		Object object=null;
		List<GoodsData>  list=null;
		if(redisOperatiorLogic.isJedisIsConnected())
		{
			object = redisOperatiorLogic.readObject(key, getOrderRedisGroupNo("1"));
		}
		if(null!=object){
			if (!object.equals("")) {
				list =  (List) object;
			}
		}
		else
		{
			list=goodsDataMapper.selectByExample(example);
			if(redisOperatiorLogic.isJedisIsConnected())
			{
			redisOperatiorLogic.setEx(key, list, getOrderRedisGroupNo("1"));
			}
		}
		return list;
		
	}
}
